<!DOCTYPE html>
<html lang="zh">

<head>
  <title>Aestate | 关于</title>
  <link rel="icon" href="images/logo_transparent.png">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">




  <link rel="stylesheet" href="css/animate.css">

  <link rel="stylesheet" href="css/owl.carousel.min.css">
  <link rel="stylesheet" href="css/owl.theme.default.min.css">
  <link rel="stylesheet" href="css/magnific-popup.css">

  <link rel="stylesheet" href="css/flaticon.css">
  <link rel="stylesheet" href="css/style.css">
</head>

<body>

  <nav class="navbar navbar-expand-lg navbar-dark ftco_navbar bg-dark ftco-navbar-light" id="ftco-navbar">
    <div class="container" style="position: relative;">
      <a class="navbar-brand" href="index.html" style="position: absolute;left: 0;width: 20%;">
        Aestate Framework
      </a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#ftco-nav"
        aria-controls="ftco-nav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="oi oi-menu"></span> Menu
      </button>

      <div class="collapse navbar-collapse" id="ftco-nav">
        <ul class="navbar-nav ml-auto">
          <li class="nav-item"><a href="index.html" class="nav-link">主页</a></li>
          <li class="nav-item active"><a href="about.html" class="nav-link">关于</a></li>
          <li class="nav-item"><a href="open.html" class="nav-link">开源</a></a></li>
          <li class="nav-item"><a class="nav-link" href="leadership.html">参与者</a></li>
          <li class="nav-item"><a href="https://gitee.com/aecode/aestate/releases" target="_blank"
              class="nav-link">更新日志</a></li>
          <li class="nav-item"><a href="https://gitee.com/aecode" target="_blank" class="nav-link">加入</a></li>
          <li class="nav-item cta"><a href="https://doc.cacode.ren" target="_blank" class="nav-link"><span>Get
                started</span></a></li>
        </ul>
      </div>
    </div>
  </nav>
  <!-- END nav -->

  <div class="hero-wrap hero-wrap-2" style="background-image: url('images/bg_1.png');"
    data-stellar-background-ratio="0.5">
    <div class="overlay"></div>
    <div class="container">
      <div class="row no-gutters slider-text align-items-end justify-content-start">
        <div class="col-md-8 ftco-animate text-center text-md-left mb-5">
          <p class="breadcrumbs mb-0"><span class="mr-3"><a href="index.html">Home <i
                  class="ion-ios-arrow-forward"></i></a></span> <span>About</span></p>
          <h1 class="mb-3 bread">About</h1>
        </div>
      </div>
    </div>
  </div>

  <section class="ftco-section ftco-faqs">
    <div class="container">
      <div class="file_content markdown-body">
        <h1 align="center">
          <a id="user-content-aestate--多样化数据库查询" class="anchor"
            href="#aestate--%E5%A4%9A%E6%A0%B7%E5%8C%96%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E8%AF%A2"></a>Aestate ——
          多样化数据库查询
        </h1>
        <p align="center">
          <a href="https://gitee.com/aecode/aestate/stargazers">
            <img src="https://svg.hamm.cn/gitee.svg?user=aecode&amp;project=aestate&amp;type=star" alt="star">
          </a>
          <img src="https://svg.hamm.cn/gitee.svg?user=aecode&amp;project=aestate&amp;type=language" alt="star">
          <img src="https://svg.hamm.cn/badge.svg?key=Python&amp;value=%3E=3.6">
          <a href="https://doc.cacode.ren" rel="nofollow">
            <img src="https://svg.hamm.cn/badge.svg?key=Documentation&amp;value=yes">
          </a>
          <a href="https://gitee.com/aecode/summer-python/blob/main/LICENSE">
            <img src="https://svg.hamm.cn/gitee.svg?user=aecode&amp;project=aestate&amp;type=license" alt="star">
          </a>
        </p>
        <h1>
          <a id="user-content-介绍" class="anchor" href="#%E4%BB%8B%E7%BB%8D"></a>介绍
        </h1>
        <blockquote>
          <p>当前测试通过数据库有:</p>
        </blockquote>
        <ul>
          <li>MySql8.0</li>
          <li>Sqlserver2019</li>
          <li>PostgreSQL 13.3</li>
        </ul>
        <p><code>Aestate Framework</code> 是一款基于<code>Python</code>语言开发的<code>ORM</code>框架， 你可以使用多种方式去实现基于对象方式的查询.</p>
        <p>也就是相对于Java语言的Mybatis-Plus</p>
        <p>比如使用类似<code>Django</code>的模式去使用：<code>modelClass.orm.filter(*args, **kwargs)</code></p>
        <p>或者SQLAlchemy的方式：<code>find().where(**kwargs).group_by(*args)</code></p>
        <p>或者像<code>Java</code>的<code>Hibernate</code>一样：</p>
        <div class="white">
          <div class="highlight">
            <pre><span id="LC1" class="line"><span class="o">@</span><span class="n">SelectAbst</span><span class="p">()</span></span>
        <span id="LC2" class="line"><span class="k">def</span> <span class="nf">find_all_F_where_id_in_and_name_like_order_by_id</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">:</span> <span class="p">...</span></span>
        <span id="LC3" class="line"></span>
        <span id="LC4" class="line"></span>
        <span id="LC5" class="line"><span class="o">@</span><span class="n">Select</span><span class="p">(</span><span class="s">"SELECT * FROM demo WHERE id=#{id} AND name=#{name}"</span><span class="p">)</span></span>
        <span id="LC6" class="line"><span class="k">def</span> <span class="nf">find_all_where_id</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">id</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span> <span class="p">...</span></span></pre>
          </div>
        </div>
        <p>或者像<code>Java</code>的<code>Mybatis</code>使用xml</p>
        <div class="white">
          <div class="highlight">
            <pre><span id="LC1" class="line"><span class="cp">&lt;?xml version="1.0"?&gt;</span></span>
        <span id="LC2" class="line"><span class="nt">&lt;aestate</span> <span class="na">xmlns:xsi=</span><span class="s">"http://www.w3.org/2001/XMLSchema-instance"</span></span>
        <span id="LC3" class="line">         <span class="na">xsi:schemaLocation=</span><span class="s">"aestate  https://gitee.com/aecode/aestate-xml/blob/main/v1/tags.xsd"</span></span>
        <span id="LC4" class="line">         <span class="na">xmlns=</span><span class="s">"aestate"</span><span class="nt">&gt;</span></span>
        <span id="LC5" class="line">    <span class="nt">&lt;template</span> <span class="na">id=</span><span class="s">"templateField"</span><span class="nt">&gt;</span></span>
        <span id="LC6" class="line">        id,name,password,create_time,update_time</span>
        <span id="LC7" class="line">        <span class="nt">&lt;description&gt;</span>测试模板<span class="nt">&lt;/description&gt;</span></span>
        <span id="LC8" class="line">    <span class="nt">&lt;/template&gt;</span></span>
        <span id="LC9" class="line">    <span class="nt">&lt;resultMap</span> <span class="na">id=</span><span class="s">"resultMapLeftJoin"</span> <span class="na">type=</span><span class="s">"example.table.demoModels.Demo"</span><span class="nt">&gt;</span></span>
        <span id="LC10" class="line">        <span class="nt">&lt;result</span> <span class="na">field=</span><span class="s">"d1_id"</span> <span class="na">properties=</span><span class="s">"id"</span><span class="nt">/&gt;</span></span>
        <span id="LC11" class="line">        <span class="nt">&lt;result</span> <span class="na">field=</span><span class="s">"d1_name"</span> <span class="na">properties=</span><span class="s">"name"</span><span class="nt">/&gt;</span></span>
        <span id="LC12" class="line">        <span class="nt">&lt;result</span> <span class="na">field=</span><span class="s">"d1_password"</span> <span class="na">properties=</span><span class="s">"password"</span><span class="nt">/&gt;</span></span>
        <span id="LC13" class="line">        <span class="nt">&lt;foreign</span> <span class="na">type=</span><span class="s">"example.table.demoModels.Demo"</span> <span class="na">name=</span><span class="s">"demoJoin"</span><span class="nt">&gt;</span></span>
        <span id="LC14" class="line">            <span class="nt">&lt;result</span> <span class="na">field=</span><span class="s">"d2_id"</span> <span class="na">properties=</span><span class="s">"id"</span><span class="nt">/&gt;</span></span>
        <span id="LC15" class="line">            <span class="nt">&lt;result</span> <span class="na">field=</span><span class="s">"d2_name"</span> <span class="na">properties=</span><span class="s">"name"</span><span class="nt">/&gt;</span></span>
        <span id="LC16" class="line">            <span class="nt">&lt;result</span> <span class="na">field=</span><span class="s">"d2_password"</span> <span class="na">properties=</span><span class="s">"password"</span><span class="nt">/&gt;</span></span>
        <span id="LC17" class="line">        <span class="nt">&lt;/foreign&gt;</span></span>
        <span id="LC18" class="line">    <span class="nt">&lt;/resultMap&gt;</span></span>
        <span id="LC19" class="line">    <span class="nt">&lt;item</span> <span class="na">id=</span><span class="s">"findAllById"</span><span class="nt">&gt;</span></span>
        <span id="LC20" class="line">        <span class="nt">&lt;select</span> <span class="na">resultType=</span><span class="s">"resultMapLeftJoin"</span><span class="nt">&gt;</span></span>
        <span id="LC21" class="line">            SELECT</span>
        <span id="LC22" class="line">            <span class="c">&lt;!-- 导入查询的字段 --&gt;</span></span>
        <span id="LC23" class="line">            <span class="c">&lt;!--            &lt;include from="templateField"/&gt;--&gt;</span></span>
        <span id="LC24" class="line">            <span class="nt">&lt;include</span> <span class="na">from=</span><span class="s">"tempSymbol"</span><span class="nt">/&gt;</span></span>
        <span id="LC25" class="line">            FROM demo as d1 LEFT JOIN demo as d2 ON d2.id = d1.id WHERE d1.id &gt;</span>
        <span id="LC26" class="line">            <span class="nt">&lt;switch</span> <span class="na">field=</span><span class="s">"id"</span><span class="nt">&gt;</span></span>
        <span id="LC27" class="line">                <span class="nt">&lt;case</span> <span class="na">value=</span><span class="s">"10"</span><span class="nt">&gt;</span>10<span class="nt">&lt;/case&gt;</span></span>
        <span id="LC28" class="line">                <span class="nt">&lt;case</span> <span class="na">value=</span><span class="s">"5"</span><span class="nt">&gt;</span>5<span class="nt">&lt;/case&gt;</span></span>
        <span id="LC29" class="line">                <span class="nt">&lt;default&gt;</span>#{id}<span class="nt">&lt;/default&gt;</span></span>
        <span id="LC30" class="line">            <span class="nt">&lt;/switch&gt;</span></span>
        <span id="LC31" class="line">            <span class="nt">&lt;if</span> <span class="na">test=</span><span class="s">"#{id}&amp;gt;=20"</span><span class="nt">&gt;</span>AND d2.id &gt; 20<span class="nt">&lt;/if&gt;</span></span>
        <span id="LC32" class="line">            <span class="nt">&lt;else&gt;</span>AND d2.id &gt; 10<span class="nt">&lt;/else&gt;</span></span>
        <span id="LC33" class="line">            LIMIT 2</span>
        <span id="LC34" class="line"></span>
        <span id="LC35" class="line">            <span class="nt">&lt;description&gt;</span></span>
        <span id="LC36" class="line">                SELECT d1.`name` as d1_name,d1.`password` as d1_password,d1.`id` as d1_id, d2.`name` as</span>
        <span id="LC37" class="line">                d2_name,d2.`password` as d2_password,d2.`id` as d2_id FROM demo as d1 LEFT JOIN demo as d2 ON d2.id =</span>
        <span id="LC38" class="line">                d1.id WHERE d1.id &gt; %s AND d2.id &gt; 10 LIMIT 2</span>
        <span id="LC39" class="line">            <span class="nt">&lt;/description&gt;</span></span>
        <span id="LC40" class="line">        <span class="nt">&lt;/select&gt;</span></span>
        <span id="LC41" class="line">    <span class="nt">&lt;/item&gt;</span></span>
        <span id="LC42" class="line"><span class="nt">&lt;/aestate&gt;</span></span></pre>
          </div>
        </div>
        <h1>
          <a id="user-content-相对于其他库有什么区别" class="anchor"
            href="#%E7%9B%B8%E5%AF%B9%E4%BA%8E%E5%85%B6%E4%BB%96%E5%BA%93%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB"></a>相对于其他库有什么区别？
        </h1>
        <ul>
          <li>
            <p>首先<strong>Aestate</strong>是基于Django、SQLAlchemy、Mybatis、Mybatis-Plus、SpringJPA整合起来的一个数据库支持库，
              融合了这么多第三方库首先一点就是他的操作方式是多种多样的。目前已有六种操作方法，
              也就是Django模式、SQLAlchemy模式、xml模式、Mybatis-Plus模式，注解模式，原生模式。</p>
          </li>
          <li>
            <p>其次就是在兼容性方面，由于这个世界上的数据库种类太多了没办法做到统一， <strong>Aestate</strong>保留了对其他小众数据库的实现接口，尽可能多兼容数据库。</p>
          </li>
          <li>
            <p>数据库表方面，Django是会生成数据django自己系统内部的表，在迁移的时候呢如果做错一步可能对于新手
              来讲后面的修复操作是极其难的，也未必能够在短时间内定位问题并修复。<strong>Aestate</strong>为了解决这个问题，将make
              和手动建表尽可能的兼容，不会生成额外的表和数据，也不会捆绑某个特定系统，将pojo/model复制出来可以直接为下一个项目使用。</p>
          </li>
          <li>
            <p>缓存方面参考了Mybatis的实现方法并略微修改，<strong>Aestate</strong>有两个内存管理模块，用于保证数据的完整性，
              当一些特别大的数据占满缓存时，<strong>Aestate</strong>会尽量多的去分配内存保证数据完整性，除外才会去管理内存（不建议操作大于系统内存2/10的数据）。<strong>Aestate</strong>有弹性内存管理方式，会根据系统的执行自动调整缓存大小，尽可能的加快运行速度，减少对数据库的连接次数。
            </p>
          </li>
          <li>
            <p>自带日志和美化，不需要下载其他插件就可以把日志变色，自动保存日志，这个功能对于爱美的大兄弟简直就 是神仙般的存在（当然也可能只有我喜欢装逼）</p>
          </li>
          <li>
            <p>还有很多......</p>
          </li>
        </ul>
        <blockquote>
          <p>寻找志同道合的朋友一起开发<strong>Aestate</strong><br>
            作者QQ:2075383131(云)<br>
            qq群：909044439(Aestate Framework)</p>
        </blockquote>
        <h1>
          <a id="user-content-先决条件" class="anchor" href="#%E5%85%88%E5%86%B3%E6%9D%A1%E4%BB%B6"></a>先决条件
        </h1>
        <blockquote>
          <p>Python &gt;=3.6 (其他版本没试过)<br>
            教程文档地址：<a href="http://doc.cacode.ren" rel="nofollow">http://doc.cacode.ren</a></p>
        </blockquote>
        <h1>
          <a id="user-content-更全面的教程和文档" class="anchor"
            href="#%E6%9B%B4%E5%85%A8%E9%9D%A2%E7%9A%84%E6%95%99%E7%A8%8B%E5%92%8C%E6%96%87%E6%A1%A3"></a>更全面的教程和文档
        </h1>
        <ul>
          <li><a href="http://doc.cacode.ren" rel="nofollow">文字教程 doc.cacode.ren</a></li>
          <li><a href="https://www.bilibili.com/video/BV1gq4y1E7Fs/" rel="nofollow">视频教程 bilibili.com</a></li>
        </ul>
        <h1>
          <a id="user-content-安装" class="anchor" href="#%E5%AE%89%E8%A3%85"></a>安装
        </h1>
        <p>目前源代码仅开放在gitee，处于组织CACode下，仓库地址为：<a href="https://gitee.com/aecode/aestate">aestate</a>
          使用pip或anaconda安装<strong>Aestate</strong>：</p>
        <div class="white">
          <div class="highlight">
            <pre><span id="LC1" class="line">pip <span class="nb">install </span>aestate</span>
        <span id="LC2" class="line"></span>
        <span id="LC3" class="line">conda <span class="nb">install </span>aestate </span></pre>
          </div>
        </div>
        <p>注意请不要用国内镜像下载，只发布在 <a href="https://pypi.org/search/?q=aestate" rel="nofollow">pypi.org</a> 也就是pip的官方源下</p>
        <blockquote>
          <p>qq群：<a href="https://jq.qq.com/?_wv=1027&amp;k=EK7YEXmh" rel="nofollow">909044439</a></p>
        </blockquote>
        <h1>
          <a id="user-content-我是新手怎么快速入门呢" class="anchor"
            href="#%E6%88%91%E6%98%AF%E6%96%B0%E6%89%8B%E6%80%8E%E4%B9%88%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8%E5%91%A2"></a>我是新手，怎么快速入门呢？
        </h1>
        <p>你可以前往<a href="https://doc.cacode.ren" rel="nofollow">https://doc.cacode.ren</a>跟着官方文档入门<br>
          也可以在B站 <a href="https://space.bilibili.com/371089110" rel="nofollow">你在写臭虫</a> 看视频学</p>
        <h1>
          <a id="user-content-操作方式太多了一下子学不会怎么办" class="anchor"
            href="#%E6%93%8D%E4%BD%9C%E6%96%B9%E5%BC%8F%E5%A4%AA%E5%A4%9A%E4%BA%86%E4%B8%80%E4%B8%8B%E5%AD%90%E5%AD%A6%E4%B8%8D%E4%BC%9A%E6%80%8E%E4%B9%88%E5%8A%9E"></a>操作方式太多了一下子学不会怎么办？
        </h1>
        <p><strong>Aestate</strong>有五种方式，不是非要全部都会，我当时写的时候只是为了把很多语言的操作方式用Python实现，然后让其他语言转Python的开发者能够找到熟悉的感觉，例如</p>
        <ol>
          <li>Java专业户：用xml、方法名和注解</li>
          <li>Python专业户：用Django模式和SQLAlchemy模式</li>
          <li>纯萌新：老老实实写SQL，先把基础练好</li>
        </ol>
        <h1>
          <a id="user-content-依赖包" class="anchor" href="#%E4%BE%9D%E8%B5%96%E5%8C%85"></a>依赖包
        </h1>
        <blockquote>
          <p>pip install aestate-json</p>
        </blockquote>
        <h1>
          <a id="user-content-谁在使用-aestate-framework-开发网站" class="anchor"
            href="#%E8%B0%81%E5%9C%A8%E4%BD%BF%E7%94%A8-aestate-framework-%E5%BC%80%E5%8F%91%E7%BD%91%E7%AB%99"></a>谁在使用
          Aestate Framework 开发网站
        </h1>
        <p>CACode： <a href="https://cacode.ren" rel="nofollow">https://cacode.ren</a><br>
          CocoZao 爬虫：<a href="https://ccz.cacode.ren" rel="nofollow">https://ccz.cacode.ren</a></p>
        <blockquote>
          <p>开源示例项目：<a href="https://gitee.com/canotf/aestate-example">gitee/aestate-example</a></p>
        </blockquote>
        <p>更多示例项目请前往</p>
        <blockquote>
          <p><a href="https://gitee.com/canotf">👉 Go to canotf`s homepage on Gitee 👈</a></p>
        </blockquote>
        <h1>
          <a id="user-content-鸣谢" class="anchor" href="#%E9%B8%A3%E8%B0%A2"></a>鸣谢
        </h1>
        <p>Cpython<br>
          DBPool<br>
          Simplejson<br>
          Gitee</p>
        <h1>
          <a id="user-content-感谢捐献" class="anchor" href="#%E6%84%9F%E8%B0%A2%E6%8D%90%E7%8C%AE"></a>感谢捐献
        </h1>
        <a href="https://gitee.com/spacexzm">
          <img alt="Spacexzm" width="49%" src="https://svg.hamm.cn/gitee-user.svg?user=spacexzm">
        </a>
        <a href="https://gitee.com/canotf">
          <img alt="Canotf" width="49%" src="https://svg.hamm.cn/gitee-user.svg?user=canotf">
        </a>
        <h1>
          <a id="user-content-cacode-development-team" class="anchor" href="#cacode-development-team"></a>CACode
          Development Team
        </h1>
      </div>
    </div>
  </section>
  <footer class="ftco-footer ftco-bg-dark ftco-section">
    <div class="container">
      <div class="row mb-5">
        <div class="col-md">
          <div class="ftco-footer-widget mb-4">
            <img src="images/logo_framework_tr.png" width="100%" alt="">
          </div>
        </div>
        <div class="col-md">
          <div class="ftco-footer-widget mb-4 ml-md-5">
            <h2 class="ftco-heading-2">快速导航</h2>
            <ul class="list-unstyled">
              <li><a href="about.html" class="py-2 d-block">组织信息</a></li>
              <li><a href="open.html" class="py-2 d-block">开源</a></li>
              <li><a href="leadership.html" class="py-2 d-block">参与者</a></li>
              <li><a href="https://gitee.com/aecode/aestate/releases" target="_blank" class="py-2 d-block">更新日志</a></li>
              <li><a href="https://gitee.com/aecode" target="_blank" class="py-2 d-block">加入我们</a></li>
            </ul>
          </div>
        </div>
        <div class="col-md">
          <div class="ftco-footer-widget mb-4">
            <h2 class="ftco-heading-2">帮助</h2>
            <ul class="list-unstyled">
              <li><a href="https://gitee.com/aecode/aestate/issues" target="_blank" class="py-2 d-block">Issues</a></li>
              <li><a href="https://gitee.com/aecode/aestate/pulls" target="_blank" class="py-2 d-block">Pull Request</a>
              </li>
              <li><a href="https://gitee.com/aecode/aestate" target="_blank" class="py-2 d-block">Source
                  Code</a></li>
              <li><a href="https://gitee.com/canotf" target="_blank" class="py-2 d-block">Author</a></li>
              <li><a href="https://doc.cacode.ren" target="_blank" class="py-2 d-block">Doc</a></li>
            </ul>
          </div>
        </div>
        <div class="col-md">
          <div class="ftco-footer-widget mb-4">
            <h2 class="ftco-heading-2">联系作者</h2>
            <div class="block-23 mb-3">
              <ul>
                <li><span class="mr-3 fa fa-map-marker"></span><span class="text">
                    广东省 广州市 天河区 华南理工大学五山校区
                  </span></li>
                <li><a href="https://jq.qq.com/?_wv=1027&k=EK7YEXmh"><span class="mr-3 fa fa-phone"></span>QQ群:<span
                      class="text">
                      909044439
                    </span></a></li>
                <li><a href="mailto:cacode@163.com"><span class="mr-3 fa fa-envelope"></span>邮箱:<span
                      class="text">cacode@163.com</span></a></li>
              </ul>
            </div>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-md-12 text-center">

          <p style="text-align:center;">Copyright ©2019 CACode
            <a rel="nofollow" target="_blank" href="http://beian.miit.gov.cn/">粤ICP备20009502</a>
          </p>
        </div>
      </div>
    </div>
  </footer>
  <div id="box" class="box">
    <img class="box-in" src="images/top.png" alt="">
  </div>
  <script src="js/jquery.min.js"></script>
  <script src="js/jquery-migrate-3.0.1.min.js"></script>
  <script src="js/popper.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script src="js/jquery.easing.1.3.js"></script>
  <script src="js/jquery.waypoints.min.js"></script>
  <script src="js/jquery.stellar.min.js"></script>
  <script src="js/owl.carousel.min.js"></script>
  <script src="js/jquery.magnific-popup.min.js"></script>
  <script src="js/jquery.animateNumber.min.js"></script>
  <script src="js/scrollax.min.js"></script>

  <script src="js/google-map.js"></script>
  <script src="js/main.js"></script>

</body>

</html>